Skip to content

refactor: use kermit-io for file logging (WPB-26806) - #5231

Merged
yamilmedina merged 5 commits into
developfrom
refactor/file-logging-aproach
Sep 2, 2026
Merged

refactor: use kermit-io for file logging (WPB-26806) #5231
yamilmedina merged 5 commits into
developfrom
refactor/file-logging-aproach

Conversation

@yamilmedina

@yamilmedina yamilmedina commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

https://wearezeta.atlassian.net/browse/WPB-26806


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

Some devices produces zero bytes logs due to vendor oem restrictions.

Causes (Optional)

The current implementation of our file logger relies on spinning off a process that runs logcat and attaches this output to a file log.

Solutions

While in the past we dealt with this issue, since it was blocking the app startup, now this enables logs on them as well by using kermit-io and it's RollingFileWritter made for this purpose.

Dependencies (Optional)

We need to stick to version 2.0.5 given a datetime constraint coming from kalium, which creates conflict resolution if upgrade to latest 2.1.0


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@yamilmedina
yamilmedina requested a review from a team as a code owner August 28, 2026 11:02
@yamilmedina
yamilmedina requested review from ohassine and valerio-bettini and removed request for a team August 28, 2026 11:02
@yamilmedina yamilmedina changed the title refactor: use kermitio for file logging (WPB-26806) refactor: use kermit-io for file logging (WPB-26806) Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Test Results

2 643 tests  +22   2 643 ✅ +22   1m 41s ⏱️ +22s
  337 suites + 4       0 💤 ± 0 
  337 files   + 4       0 ❌ ± 0 

Results for commit 6c180d5. ± Comparison against base commit 007c1bb.

This pull request removes 2 and adds 24 tests. Note that renamed tests count towards both.
com.wire.android.feature.meetings.ui.options.MeetingOptionsMenuViewModelTest ‑ givenPastMeeting_andSelfUserIsCreator_whenObserving_thenEditAndDeleteIsNotAvailable()
com.wire.android.ui.home.HomeTopLevelNavigation3Test ‑ givenWhatsNewItems_whenMapped_thenOnlySemanticNavigation3TargetsCrossTheHomeBoundary()
com.wire.android.feature.meetings.ui.create.MeetingsNavigation3SourceTest ‑ meetings Home root owns a framework neutral action bundle()
com.wire.android.feature.meetings.ui.create.NewMeetingViewModelTest ‑ givenEditTypeWithStartAndEndTimesInPast_whenSubmitUpdateIsCalled_thenPastTimesAreAllowedAndMeetingIsEdited()
com.wire.android.feature.meetings.ui.create.NewMeetingViewModelTest ‑ givenScheduleTypeWithStartAndEndTimesInPast_whenSubmitCreationIsCalled_thenPastTimeErrorsAreShownAndMeetingIsNotCreated()
com.wire.android.feature.meetings.ui.options.MeetingOptionsMenuViewModelTest ‑ givenPastMeeting_andSelfUserIsCreator_whenObserving_thenEditIsNotAvailableAndDeleteForEveryoneIsAvailable()
com.wire.android.feature.meetings.ui.options.MeetingOptionsMenuViewModelTest ‑ givenPastMeeting_andSelfUserIsMember_whenObserving_thenEditAndDeleteIsNotAvailable()
com.wire.android.navigation.runtime.WireNavigation3ProductionActionsTest ‑ given conversation list start action, when invoked, then typed new-conversation route is navigated()
com.wire.android.ui.WireActivityNewIntentCallerTest ‑ givenAndroid14_whenReplacingIntent_thenUsesLegacyIntentSetter
com.wire.android.ui.WireActivityNewIntentCallerTest ‑ givenAndroid15_whenReplacingIntent_thenRetainsCurrentCaller
com.wire.android.ui.home.HomeTopLevelNavigation3Test ‑ givenHomeShellActions_whenDefiningNavigation_thenChildNavigationIsOnlyExposedThroughTopLevel()
com.wire.android.ui.home.HomeTopLevelNavigation3Test ‑ givenHomeTopLevelActions_whenDefiningChildNavigation_thenEveryChildUsesAnOwnedContract()
…

♻️ This comment has been updated with latest results.

@github-actions

Copy link
Copy Markdown
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@yamilmedina
yamilmedina requested review from saleniuk and removed request for valerio-bettini August 28, 2026 12:18
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.00000% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.67%. Comparing base (e73dcbe) to head (a815c8d).

Files with missing lines Patch % Lines
...com/wire/android/util/logging/LogFileWriterImpl.kt 68.60% 3 Missing and 24 partials ⚠️
...om/wire/android/ui/debug/LogManagementViewModel.kt 0.00% 3 Missing ⚠️
...in/com/wire/android/ui/debug/UserDebugViewModel.kt 0.00% 3 Missing ⚠️
...rc/main/kotlin/com/wire/android/WireApplication.kt 83.33% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (66.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5231      +/-   ##
===========================================
+ Coverage    52.26%   52.67%   +0.41%     
===========================================
  Files          745      745              
  Lines        25897    25819      -78     
  Branches      4235     4239       +4     
===========================================
+ Hits         13534    13601      +67     
+ Misses       11066    10897     -169     
- Partials      1297     1321      +24     
Files with missing lines Coverage Δ
...lin/com/wire/android/util/logging/LogFileWriter.kt 0.00% <ø> (ø)
...m/wire/android/util/logging/LogFileWriterConfig.kt 75.00% <100.00%> (+75.00%) ⬆️
...rc/main/kotlin/com/wire/android/WireApplication.kt 4.80% <83.33%> (+0.92%) ⬆️
...om/wire/android/ui/debug/LogManagementViewModel.kt 0.00% <0.00%> (ø)
...in/com/wire/android/ui/debug/UserDebugViewModel.kt 0.00% <0.00%> (ø)
...com/wire/android/util/logging/LogFileWriterImpl.kt 68.96% <68.60%> (+68.96%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e73dcbe...a815c8d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@AndroidBob

Copy link
Copy Markdown
Collaborator

New ADR(s) in this PR 📚:

15. Replace logcat-process capture with direct diagnostic file logging

Date: 2026-09-02

Status

Accepted

Context

The previous Android diagnostic logger started a logcat process and copied its output into
wire_logs.txt, with timestamped gzip rolls. That approach depends on device-specific logcat
availability, permissions and process behavior. It can produce empty diagnostic files on some
OEM/vendor devices even while the application is running normally, which makes support reports
unreliable precisely where logs are needed most.

Application and Kalium diagnostics already flow through Kermit. Writing that stream directly to a
rolling file avoids relying on the platform logcat process. The direct writer stores
wire_logs.log and numbered rolls in the same directory, so upgraded installations also need a
safe transition for existing legacy files.

The current app packages diagnostic files into a single ZIP archive. This established export
behavior must be retained while preserving a useful legacy diagnostic snapshot and avoiding data
loss if migration is interrupted or filesystem operations fail.

Decision

The app writes Kermit diagnostics directly to a rolling file and does not use a logcat process
for diagnostic file collection. Application and Kalium log writers feed the same direct writer,
subject to the existing logging enablement and log-level configuration.

When direct file logging starts, the app migrates a legacy wire_logs.txt file before opening the
rolling writer.

  • Compress the legacy active file into the deterministic wire_legacy_active.gz through a
    temporary sibling file.
  • Validate and finalize the gzip snapshot before deleting the legacy source.
  • After a valid snapshot exists, remove only recognized legacy archives and temporary remnants.
  • On startup after an interruption, treat a valid snapshot as the committed state and finish
    cleanup without creating another snapshot.
  • If compression or finalization fails, retain the legacy source and history, then continue with
    direct logging.
  • Delete logs removes recognized legacy files, the retained snapshot, and direct rolling files;
    unrelated files in the directory are preserved.
  • Diagnostic sharing remains a single ZIP archive. The snapshot is included naturally as an entry
    alongside current rolling logs.

Consequences

Diagnostic logging no longer depends on an OEM's logcat process behavior, so files contain the
events emitted by the application's configured Kermit writers on supported devices. Users retain
at most one compressed view of the legacy active log after upgrade, and support exports contain
both pre-upgrade and current diagnostics without changing their ZIP format.

The direct approach records only logs routed through Kermit; it intentionally does not capture
arbitrary system or third-party logcat output. Migration adds a small amount of filesystem work on
the first enabled direct-logging startup and requires focused tests for successful migration,
failed finalization, restart recovery, deletion, and ZIP contents. The filename allow-list must
be maintained if diagnostic log naming changes.

@yamilmedina
yamilmedina added this pull request to the merge queue Sep 2, 2026
Merged via the queue into develop with commit a5475d0 Sep 2, 2026
19 checks passed
@yamilmedina
yamilmedina deleted the refactor/file-logging-aproach branch September 2, 2026 15:16
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants